//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_exported import SotoCore

/// Service object for interacting with AWS BCMDashboards service.
///
/// Amazon Web Services Billing and Cost Management Dashboards is a service that enables you to create, manage, and share dashboards that combine multiple visualizations of your Amazon Web Services cost and usage data. You can combine multiple data sources including Cost Explorer, Savings Plans, and Reserved Instance metrics into unified dashboards, helping you analyze spending patterns and share cost insights across your organization. You can use the Amazon Web Services Billing and Cost Management Dashboards API to programmatically create, manage, and share dashboards. This includes creating custom dashboards, configuring widgets, managing dashboard permissions, and sharing dashboards across accounts in your organization.
public struct BCMDashboards: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the BCMDashboards client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - middleware: Middleware chain used to edit requests before they are sent and responses before they are decoded 
    ///     - timeout: Timeout value for HTTP requests
    ///     - byteBufferAllocator: Allocator for ByteBuffers
    ///     - options: Service options
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        middleware: AWSMiddlewareProtocol? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            amzTarget: "AWSBCMDashboardsService",
            serviceName: "BCMDashboards",
            serviceIdentifier: "bcm-dashboards",
            serviceProtocol: .json(version: "1.0"),
            apiVersion: "2025-08-18",
            endpoint: endpoint,
            errorType: BCMDashboardsErrorType.self,
            middleware: middleware,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }





    // MARK: API Calls

    /// Creates a new dashboard that can contain multiple widgets displaying cost and usage data. You can add custom widgets or use predefined widgets, arranging them in your preferred layout.
    @Sendable
    @inlinable
    public func createDashboard(_ input: CreateDashboardRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> CreateDashboardResponse {
        try await self.client.execute(
            operation: "CreateDashboard", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Creates a new dashboard that can contain multiple widgets displaying cost and usage data. You can add custom widgets or use predefined widgets, arranging them in your preferred layout.
    ///
    /// Parameters:
    ///   - description: A description of the dashboard's purpose or contents.
    ///   - name: The name of the dashboard. The name must be unique within your account.
    ///   - resourceTags: The tags to apply to the dashboard resource for organization and management.
    ///   - widgets: An array of widget configurations that define the visualizations to be displayed in the dashboard. Each dashboard can contain up to 20 widgets.
    ///   - logger: Logger use during operation
    @inlinable
    public func createDashboard(
        description: String? = nil,
        name: String,
        resourceTags: [ResourceTag]? = nil,
        widgets: [Widget],
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> CreateDashboardResponse {
        let input = CreateDashboardRequest(
            description: description, 
            name: name, 
            resourceTags: resourceTags, 
            widgets: widgets
        )
        return try await self.createDashboard(input, logger: logger)
    }

    /// Deletes a specified dashboard. This action cannot be undone.
    @Sendable
    @inlinable
    public func deleteDashboard(_ input: DeleteDashboardRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> DeleteDashboardResponse {
        try await self.client.execute(
            operation: "DeleteDashboard", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Deletes a specified dashboard. This action cannot be undone.
    ///
    /// Parameters:
    ///   - arn: The ARN of the dashboard to be deleted.
    ///   - logger: Logger use during operation
    @inlinable
    public func deleteDashboard(
        arn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> DeleteDashboardResponse {
        let input = DeleteDashboardRequest(
            arn: arn
        )
        return try await self.deleteDashboard(input, logger: logger)
    }

    /// Retrieves the configuration and metadata of a specified dashboard, including its widgets and layout settings.
    @Sendable
    @inlinable
    public func getDashboard(_ input: GetDashboardRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> GetDashboardResponse {
        try await self.client.execute(
            operation: "GetDashboard", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Retrieves the configuration and metadata of a specified dashboard, including its widgets and layout settings.
    ///
    /// Parameters:
    ///   - arn: The ARN of the dashboard to retrieve. This is required to uniquely identify the dashboard.
    ///   - logger: Logger use during operation
    @inlinable
    public func getDashboard(
        arn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetDashboardResponse {
        let input = GetDashboardRequest(
            arn: arn
        )
        return try await self.getDashboard(input, logger: logger)
    }

    /// Retrieves the resource-based policy attached to a dashboard, showing sharing configurations and permissions.
    @Sendable
    @inlinable
    public func getResourcePolicy(_ input: GetResourcePolicyRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> GetResourcePolicyResponse {
        try await self.client.execute(
            operation: "GetResourcePolicy", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Retrieves the resource-based policy attached to a dashboard, showing sharing configurations and permissions.
    ///
    /// Parameters:
    ///   - resourceArn: The ARN of the dashboard whose resource-based policy you want to retrieve.
    ///   - logger: Logger use during operation
    @inlinable
    public func getResourcePolicy(
        resourceArn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetResourcePolicyResponse {
        let input = GetResourcePolicyRequest(
            resourceArn: resourceArn
        )
        return try await self.getResourcePolicy(input, logger: logger)
    }

    /// Returns a list of all dashboards in your account.
    @Sendable
    @inlinable
    public func listDashboards(_ input: ListDashboardsRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> ListDashboardsResponse {
        try await self.client.execute(
            operation: "ListDashboards", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Returns a list of all dashboards in your account.
    ///
    /// Parameters:
    ///   - maxResults: The maximum number of results to return in a single call. The default value is 20.
    ///   - nextToken: The token for the next page of results. Use the value returned in the previous response.
    ///   - logger: Logger use during operation
    @inlinable
    public func listDashboards(
        maxResults: Int? = nil,
        nextToken: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListDashboardsResponse {
        let input = ListDashboardsRequest(
            maxResults: maxResults, 
            nextToken: nextToken
        )
        return try await self.listDashboards(input, logger: logger)
    }

    /// Returns a list of all tags associated with a specified dashboard resource.
    @Sendable
    @inlinable
    public func listTagsForResource(_ input: ListTagsForResourceRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> ListTagsForResourceResponse {
        try await self.client.execute(
            operation: "ListTagsForResource", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Returns a list of all tags associated with a specified dashboard resource.
    ///
    /// Parameters:
    ///   - resourceArn: The unique identifier for the resource.
    ///   - logger: Logger use during operation
    @inlinable
    public func listTagsForResource(
        resourceArn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListTagsForResourceResponse {
        let input = ListTagsForResourceRequest(
            resourceArn: resourceArn
        )
        return try await self.listTagsForResource(input, logger: logger)
    }

    /// Adds or updates tags for a specified dashboard resource.
    @Sendable
    @inlinable
    public func tagResource(_ input: TagResourceRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> TagResourceResponse {
        try await self.client.execute(
            operation: "TagResource", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Adds or updates tags for a specified dashboard resource.
    ///
    /// Parameters:
    ///   - resourceArn: The unique identifier for the resource.
    ///   - resourceTags: The tags to add to the dashboard resource.
    ///   - logger: Logger use during operation
    @inlinable
    public func tagResource(
        resourceArn: String,
        resourceTags: [ResourceTag],
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> TagResourceResponse {
        let input = TagResourceRequest(
            resourceArn: resourceArn, 
            resourceTags: resourceTags
        )
        return try await self.tagResource(input, logger: logger)
    }

    /// Removes specified tags from a dashboard resource.
    @Sendable
    @inlinable
    public func untagResource(_ input: UntagResourceRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> UntagResourceResponse {
        try await self.client.execute(
            operation: "UntagResource", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Removes specified tags from a dashboard resource.
    ///
    /// Parameters:
    ///   - resourceArn: The unique identifier for the resource.
    ///   - resourceTagKeys: The keys of the tags to remove from the dashboard resource.
    ///   - logger: Logger use during operation
    @inlinable
    public func untagResource(
        resourceArn: String,
        resourceTagKeys: [String],
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> UntagResourceResponse {
        let input = UntagResourceRequest(
            resourceArn: resourceArn, 
            resourceTagKeys: resourceTagKeys
        )
        return try await self.untagResource(input, logger: logger)
    }

    /// Updates an existing dashboard's properties, including its name, description, and widget configurations.
    @Sendable
    @inlinable
    public func updateDashboard(_ input: UpdateDashboardRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> UpdateDashboardResponse {
        try await self.client.execute(
            operation: "UpdateDashboard", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Updates an existing dashboard's properties, including its name, description, and widget configurations.
    ///
    /// Parameters:
    ///   - arn: The ARN of the dashboard to update.
    ///   - description: The new description for the dashboard. If not specified, the existing description is retained.
    ///   - name: The new name for the dashboard. If not specified, the existing name is retained.
    ///   - widgets: The updated array of widget configurations for the dashboard. Replaces all existing widgets.
    ///   - logger: Logger use during operation
    @inlinable
    public func updateDashboard(
        arn: String,
        description: String? = nil,
        name: String? = nil,
        widgets: [Widget]? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> UpdateDashboardResponse {
        let input = UpdateDashboardRequest(
            arn: arn, 
            description: description, 
            name: name, 
            widgets: widgets
        )
        return try await self.updateDashboard(input, logger: logger)
    }
}

extension BCMDashboards {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are not public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: BCMDashboards, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}

// MARK: Paginators

@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
extension BCMDashboards {
    /// Return PaginatorSequence for operation ``listDashboards(_:logger:)``.
    ///
    /// - Parameters:
    ///   - input: Input for operation
    ///   - logger: Logger used for logging
    @inlinable
    public func listDashboardsPaginator(
        _ input: ListDashboardsRequest,
        logger: Logger = AWSClient.loggingDisabled
    ) -> AWSClient.PaginatorSequence<ListDashboardsRequest, ListDashboardsResponse> {
        return .init(
            input: input,
            command: self.listDashboards,
            inputKey: \ListDashboardsRequest.nextToken,
            outputKey: \ListDashboardsResponse.nextToken,
            logger: logger
        )
    }
    /// Return PaginatorSequence for operation ``listDashboards(_:logger:)``.
    ///
    /// - Parameters:
    ///   - maxResults: The maximum number of results to return in a single call. The default value is 20.
    ///   - logger: Logger used for logging
    @inlinable
    public func listDashboardsPaginator(
        maxResults: Int? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) -> AWSClient.PaginatorSequence<ListDashboardsRequest, ListDashboardsResponse> {
        let input = ListDashboardsRequest(
            maxResults: maxResults
        )
        return self.listDashboardsPaginator(input, logger: logger)
    }
}

extension BCMDashboards.ListDashboardsRequest: AWSPaginateToken {
    @inlinable
    public func usingPaginationToken(_ token: String) -> BCMDashboards.ListDashboardsRequest {
        return .init(
            maxResults: self.maxResults,
            nextToken: token
        )
    }
}
